package cn.gok.homework;


class Worker{
    private String name;
    private String job;
    private int salary;

    public float dojob(int mouths){
        System.out.println(this.name+"在"+this.job+"岗位工作了"+mouths+"个月，总工资为：");
        return mouths * this.salary;
    }

    public Worker(String name, String job, int salary) {
        this.name = name;
        this.job = job;
        this.salary = salary;
    }

    @Override
    public String toString() {
        return "Worker{" +
                "name='" + name + '\'' +
                ", job='" + job + '\'' +
                ", salary=" + salary +
                '}';
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getJob() {
        return job;
    }
    public void setJob(String job) {
        this.job = job;
    }
    public int getSalary() {
        return salary;
    }
    public void setSalary(int salary) {
        this.salary = salary;
    }

}

class SuperWorker extends Worker{
    private float bonus;

    public SuperWorker(String name, String job, int salary,float bonus) {
        super(name, job, salary);
        this.bonus = bonus;
    }

    public float getBonus() {
        return bonus;
    }

    public void setBonus(float bonus) {
        if (bonus>=0&&bonus<=1) {
            this.bonus = bonus;
        }else {
            System.out.println("bonus范围在[0,1]之间");
        }
    }
    @Override
    public float dojob(int mouths) {
        return super.dojob(mouths)*(1+this.bonus);
    }

    public float dojob(int months,int addtionalHours) {
        return (int) (super.dojob(months)+(this.bonus*getSalary()*addtionalHours)/100);
    }
}


public class Homework2 {
    public static void main(String[] args) {
        Worker worker=new Worker("曰卯","java程序员",1000);
        System.out.println(worker.dojob(5));

        SuperWorker superWorker=new SuperWorker("曰印","python程序员",1000,0.3f);
        System.out.println(superWorker.dojob(5));

        System.out.println(superWorker.dojob(5,200));

    }
}